package msc.ai.mas.creditcard;

import java.io.Serializable;

public class CreditCard implements Serializable
{
	public static final int CC_STATE_ACTIVE = 1;
	public static final int CC_STATE_BLOCKED = 2;
	public static final int CC_STATE_EXPIRED = 3;
	public static final int CC_STATE_FRAUD = 4;
	
	
	private String userName;
	private String addLine1;
	private String addLine2;
	private String addCity;
	private String addState;
	private String addZipCode;
	private String addCountry;	
	private String creditCardNo;
	private String creditCVVNo;
	private String creditCardType;	
	private Double ccLimit;
	private Double currentBalance;
	private int expireYear;
	private int expireMonth;
	private int ccStatus;
	private String issuingBank;
	
	
	public CreditCard(String ccNumber, Double ccLimit, Double curBalance, int ccStatus)
	{
		this.creditCardNo = ccNumber;
		this.ccLimit = ccLimit;
		this.currentBalance = curBalance;
		this.ccStatus = ccStatus;
		
	}
	
	public 	boolean validateCCInfo(String ccNumber, String cvv,String type)
	{
		if (this.creditCardNo.equalsIgnoreCase(ccNumber) &&
				this.creditCVVNo.equalsIgnoreCase(cvv) &&
				this.creditCardType.equalsIgnoreCase(type) &&
				this.ccStatus == CreditCard.CC_STATE_ACTIVE
				
				)
		{
			return true;
		}
		else
		{
			return false;
		}
		
	}
	
	public boolean doCCTxn(double txnAmt)
	{
		boolean txnState = false;
		synchronized (currentBalance)
		{
			if (txnAmt <= this.currentBalance && txnAmt <= this.ccLimit)
			{
				this.currentBalance -= txnAmt;
				txnState = true;
			}
		}
		return txnState;
	}
	
	public boolean makePayment(double pmtAmt)
	{
		
		return false;
	}

	public String getUserName()
	{
		return userName;
	}

	public void setUserName(String userName)
	{
		this.userName = userName;
	}

	public String getAddLine1()
	{
		return addLine1;
	}

	public void setAddLine1(String addLine1)
	{
		this.addLine1 = addLine1;
	}

	public String getAddLine2()
	{
		return addLine2;
	}

	public void setAddLine2(String addLine2)
	{
		this.addLine2 = addLine2;
	}

	public String getAddCity()
	{
		return addCity;
	}

	public void setAddCity(String addCity)
	{
		this.addCity = addCity;
	}

	public String getAddState()
	{
		return addState;
	}

	public void setAddState(String addState)
	{
		this.addState = addState;
	}

	public String getAddZipCode()
	{
		return addZipCode;
	}

	public void setAddZipCode(String addZipCode)
	{
		this.addZipCode = addZipCode;
	}

	public String getAddCountry()
	{
		return addCountry;
	}

	public void setAddCountry(String addCountry)
	{
		this.addCountry = addCountry;
	}

	public String getCreditCardNo()
	{
		return creditCardNo;
	}

	public void setCreditCardNo(String creditCardNo)
	{
		this.creditCardNo = creditCardNo;
	}

	public String getCreditCVVNo()
	{
		return creditCVVNo;
	}

	public void setCreditCVVNo(String creditCVVNo)
	{
		this.creditCVVNo = creditCVVNo;
	}

	public String getCreditCardType()
	{
		return creditCardType;
	}

	public void setCreditCardType(String creditCardType)
	{
		this.creditCardType = creditCardType;
	}

	public double getCcLimit()
	{
		return ccLimit;
	}

	public void setCcLimit(double ccLimit)
	{
		this.ccLimit = ccLimit;
	}

	public double getCurrentBalance()
	{
		return currentBalance;
	}

	public void setCurrentBalance(double currentBalance)
	{
		this.currentBalance = currentBalance;
	}

	public int getExpireYear()
	{
		return expireYear;
	}

	public void setExpireYear(int expireYear)
	{
		this.expireYear = expireYear;
	}

	public int getExpireMonth()
	{
		return expireMonth;
	}

	public void setExpireMonth(int expireMonth)
	{
		this.expireMonth = expireMonth;
	}

	public int getCcStatus()
	{
		return ccStatus;
	}

	public void setCcStatus(int ccStatus)
	{
		this.ccStatus = ccStatus;
	}
	
	
	
	
	
}
